package com.zcoj.wx.handler;

import com.zcoj.wx.service.impl.WxSendTemplateMsgImpl;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.session.WxSessionManager;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author <a href="https://github.com/binarywang">Binary Wang</a>
 */
@Component
public class ScanHandler extends AbstractHandler {
    @Autowired
    private WxSendTemplateMsgImpl wxSendTemplateMsg;

    @Override
    public WxMpXmlOutMessage handle(WxMpXmlMessage wxMpXmlMessage, Map<String, Object> map,
                                    WxMpService wxMpService, WxSessionManager wxSessionManager) throws WxErrorException {
        // 扫码事件处理

        Map<String, Object> allFieldsMap = wxMpXmlMessage.getAllFieldsMap();
        wxSendTemplateMsg.SetWxMpService(wxMpService);
        wxSendTemplateMsg.checkMsgType( allFieldsMap);
        return null;
    }
}
